<#include "../menu.html.ftl">
<html>
 <head> 
	<title>V&auml;stra G&ouml;talandsregionen - Skapa s&ouml;kning</title>
   	
   	<link rel="stylesheet" type="text/css" href="/alfresco/scripts/yui_vgr/build/tabview/assets/skins/sam/tabview.css">
   	<link rel="stylesheet" type="text/css" href="/alfresco/css/vgr/createsearch.css" />
   	<script type="text/javascript" src="/alfresco/scripts/yui_vgr/build/yahoo-dom-event/yahoo-dom-event.js"></script>
   	<script type="text/javascript" src="/alfresco/scripts/yui_vgr/build/element/element-beta-min.js"></script>
   	<script type="text/javascript" src="/alfresco/scripts/yui_vgr/build/tabview/tabview-min.js"></script>
   	<script type="text/javascript" src="/alfresco/scripts/jquery/jquery.js"></script>
</head>
 <body class="yui-skin-sam">
 
 	<div class="Container">
 
 	<div class="first_header">
 		<#if editMode>
			Redigera s&ouml;kning
		<#else>
			Skapa s&ouml;kning
		</#if>
 	</div>
 	<@menu />
 	
 	<div id="create-search" class="yui-navset">
 		<ul class="yui-nav">
        	<li class="selected"><a href="#metadata"><em>1. Fyll i metadata om listan</em></a></li>
        	<li><a href="#search-conditions"><em>2. Fyll i s&ouml;kvillkor</em></a></li>
        	<li><a href="#view-options"><em>3. Visningsalternativ</em></a></li>
    	</ul>
    	 <div class="yui-content">
    	 	<div id="metadata">
    	 		<table width="650px" cellspacing="0" cellpadding="4">
    	 		<#if editMode>
					<form id="create-search-form" action="${url.service}?alf_method=PUT" method="post" accept-charset="utf-8">
				<#else>
					<form id="create-search-form" action="${url.service}" method="post" accept-charset="utf-8">
				</#if>
    	 		<tbody>
					<tr><td colspan="4"><h3>Fyll i metadata om listan</h3></td></tr>
					<tr>
						<td>Typ av lista:</td>
						<td>
							<select id="list-type" name="list-type">
								<#assign listType = (savedSearch.properties['vgr:listType'])!"Automatisk" >
									<#list valuesForListType as i>
    									<#if i == listType >
    										<option selected="yes" value="${i}">${i}</option>
    									<#else>
    										<option value="${i}">${i}</option>
    									</#if>
   									</#list>
							</select>
						</td>
					</tr>
					<tr>
						<td>Namn p&aring; lista:</td>
						<td><input type="text" id="list-name" name="list-name" size="30" value="${(savedSearch.properties['vgr:listName'])!""}" /></td>
					</tr>
					<tr>
						<td>Beskrivning:</td>
						<td>
							<textarea id="list-description" name="list-description" cols="34" rows="5">${(savedSearch.properties['vgr:listDescription']?trim)!""}</textarea>
						</td>
					</tr>
					<tr>
						<td>F&ouml;rvaltning/bolag:</td>
						<td>
							<select id="list-administration" name="list-administration">
								
								<#assign listAdm = (savedSearch.properties['vgr:listAdministration'])!"" >
								<#list valuesForAdministration as i>
    								<#if i == listAdm >
    									<option selected="yes" value="${i}">${i}</option>
    								<#else>
    									<option value="${i}">${i}</option>
    								</#if>
   								</#list>
							</select>
						</td>
					</tr>
					<tr>
						<td>Huvudomr&aring;de:</td>
						<td>
							<select id="list-majorarea" name="list-majorarea">
								<#assign listMajorArea = (savedSearch.properties['vgr:listMajorArea'])!"" >
								<#list valuesForMajorArea as i>
									<#if i == listMajorArea >
    									<option selected="yes" value="${i}">${i}</option>
    								<#else>
    									<option value="${i}">${i}</option>
    								</#if>
   								</#list>
							</select>
						</td>
					</tr>
					<tr>
						<td></td>
						<td align="right"><input type="button" class="button" value="N&auml;sta" onclick="nextTab(); return false;"></td>
					</tr>
					</tbody>
    	 			</table>
    	 	</div>
    	 	
    	 	<div id="search-conditions">
    	 		<table width="650px" cellspacing="0" cellpadding="4">
    	 		<tbody>
    	 		<tr><td colspan="4"><h3>Fyll i s&ouml;kvillkor</h3></td></tr>
  				<tr><td colspan="4"><b>Dokumentattribut</b></td></tr>
				<tr>
					<td>Dokumenttyp:</td>
					<td>
						<select id="search-doctype" name="search-doctype">
							<#list valuesForDocType as i>
								<#if i == searchDocType>
    								<option selected="yes" value="${i}">${i}</option>
    							<#else>
    								<option value="${i}">${i}</option>
    							</#if>
   							</#list>
						</select>
					</td>
				</tr>
				<tr>
					<td>Dokumenttitel:</td>
					<td><input type="text" id="search-doctitle" name="search-doctitle" size="30" value="${(searchDocTitle)!""}" /></td>
				</tr>
				<tr>
					<td>DokumentID:</td>
					<td><input type="text" id="search-docid" name="search-docid" size="30" value="${(searchDocId)!""}" /></td>
				</tr>
				<tr>
					<td>Skapat av:</td>
					<td><input type="text" id="search-doccreatedby" name="search-doccreatedby" size="30" value="${(searchDocCreatedBy)!""}"/></td>
				</tr>
				<tr>
					<td>Dokumentbeskrivning:</td>
					<td><input type="text" id="search-docdescription" name="search-docdescription" size="30" value="${(searchDocDescription)!""}" /></td>
				</tr>
		
				<tr><td colspan="4"><b>Skapat av</b></td></tr>
				<tr>
					<td>F&ouml;rfattare:</td>
					<td><input type="text" id="search-createdbyauthor" name="search-createdbyauthor" size="30" value="${(searchCreatedbyAuthor)!""}"/></td>
				</tr>
				<tr>
					<td>F&ouml;rvaltning/bolag/myndighet:</td>
					<td>
						<select id="search-createdbyadministration" name="search-createdbyadministration">
						<#list valuesForAdministration as i>
							<#if i == searchCreatedbyAdministration>
    							<option selected="yes" value="${i}">${i}</option>
    						<#else>
    							<option value="${i}">${i}</option>
    						</#if>
   						</#list>
						</select>
					</td>
				</tr>
				<tr>
					<td>Enhet:</td>
					<td>
						<select id="search-createdbyunit" name="search-createdbyunit">
							<#list valuesForUnit as i>
								<#if i == searchCreatedByUnit >
    								<option selected="yes" value="${i}">${i}</option>
    							<#else>
    								<option value="${i}">${i}</option>
    							</#if>
   							</#list>
						</select>
					</td>
				</tr>
				<tr><td colspan="4"><b>Ansvarig</b></td></tr>
				<tr>
					<td>Linjechef:</td>
					<td><input type="text" id="search-responsiblename" name="search-responsiblename" size="30" value="${(searchResponsibleName)!""}" /></td>
				</tr>
				<tr>
					<td>F&ouml;rvaltning/bolag/myndighet:</td>
					<td>
						<select id="search-responsibleadministration" name="search-responsibleadministration">
							<#list valuesForAdministration as i>
								<#if i == searchResponsibleAdministration >
    								<option selected="yes" value="${i}">${i}</option>
    							<#else>
    								<option value="${i}">${i}</option>
    							</#if>
   							</#list>
						</select>
					</td>
				</tr>
				<tr>
					<td>Enhet:</td>
					<td>				
						<select id="search-responsibleunit" name="search-responsibleunit">
							<#list valuesForUnit as i>
								<#if i == searchResponsibleUnit >
    								<option selected="yes" value="${i}">${i}</option>
    							<#else>
    								<option value="${i}">${i}</option>
    							</#if>
   							</#list>
						</select>
					</td>
				</tr>
		
				<tr><td colspan="4"><b>Verksamhetskategori</b></td></tr>
				<tr>
					<td>Huvudomr&aring;de:</td>
					<td>
						<select id="search-businessmajorarea" name="search-businessmajorarea">
							<#list valuesForMajorArea as i>
								<#if i == searchBusinessMajorArea>
    								<option selected="yes" value="${i}">${i}</option>
    							<#else>
    								<option value="${i}">${i}</option>
    							</#if>
   							</#list>
						</select>
					</td>
				</tr>
				<tr>
					<td>Delomr&aring;de:</td>
					<td>
						<select id="search-businessminorarea" name="search-businessminorarea">
							<#list valuesForMinorArea as i>
								<#if i == searchBusinessMinorArea>
    								<option selected="yes" value="${i}">${i}</option>
    							<#else>
    								<option value="${i}">${i}</option>
    							</#if>
   							</#list>
						</select>
					</td>
				</tr>
				<tr>
					<td>Projekt/uppdrag:</td>
					<td><input type="text" id="search-businessproject" name="search-businessproject" size="30" value="${(searchBusinessProject)!""}" /></td>
				</tr>
				<tr class="selectedItemsRow">
					<td>Uppdragsgivare:</td>
					<td><input type="text" id="search-businessassigner" name="search-businessassigner" size="30" value="${(searchBusinessAssigner)!""}" /></td>
				</tr>
				<tr><td colspan="4"><b>Referens</b></td></tr>
				<tr>
					<td>Dokumentserie:</td>
					<td><input type="text" id="search-referencedocumentsuite" name="search-referencedocumentsuite" size="30" value="${(searchReferenceDocumentSuite)!""}" /></td>
				</tr>
				<tr>
					<td>Referensnummer:</td>
					<td><input type="text" id="search-referencenumber" name="search-referencenumber" size="30" value="${(searchReferenceNumber)!""}" /></td>
				</tr>
		
				<tr><td colspan="4"><b>&ouml;vrigt</b></td></tr>
				<tr>
					<td>&aring;tkomstzon:</td>
					<td>
						<!-- TODO What should we do with this? -->
						<select id="accesszone" name="accesszone">
							<option value=""></option>
  							<option value="internet">Internet</option>
  							<option value="intranet">Intran&auml;t</option>
						</select>
					</td>
				</tr>
				
				<tr>
					<td></td>
					<td align="right">
						<input type="button" class="button" value="F&ouml;reg&aring;ende" onclick="previousTab(); return false;">
						<input type="button" class="button" value="N&auml;sta" onclick="nextTab(); return false;">
					</td>
				</tr>
				</tbody>
    	 		</table>
    	 		
    	 	</div>
    	 	
    	 	<div id="view-options">
    	 		<table width="650px" cellspacing="0" cellpadding="4">
				<tbody>		
					<tr class="selectedItemsRowAlt"><td colspan="4"><h3>Visningsalternativ</h3></td></tr>
					<tr class="selectedItemsRow">
						<td>Version:</td>
						<td><input type="checkbox" id="version-all" name="version-all" ${(showAllVersions)!""} />Visa alla versioner</td>
					</tr>
					<tr class="selectedItemsRow">
						<td>Kolumner:</td>
						<td>
							<input type="checkbox" id="column-docid"   name="column-docid" ${(columnDocId)!""} />DokumentID<br>
							<input type="checkbox" id="column-doctype" name="column-doctype" ${(columnDocType)!""} />Dokumenttyp<br>
							<input type="checkbox" id="column-version" name="column-version" ${(columnVersion)!""} />Version<br>
							<input type="checkbox" id="column-author"  name="column-author" ${(columnAuthor)!""} />F&ouml;rfattare<br>
							<input type="checkbox" id="column-responsiblename" name="column-responsiblename" ${(columnResponsibleName)!""} />Ansvarig(Linjechef)<br>
							<input type="checkbox" id="column-publishedat" name="column-publishedat" ${(columnPublishedAt)!""} />Publiceringsdatum<br>
						</td>
					</tr>
		
					<tr class="selectedItemsRow">
						<td>Ytterligare alternativ:</td>
						<td>
							<input type="checkbox" id="more-showicon" name="more-showicon" ${(showIcon)!""} /> Visa info-ikon<br>
							<input type="checkbox" id="more-showdescription" name="more-showdescription" ${(showDescription)!""} /> Visa beskrivning
						</td>
					</tr>
		
					<tr class="selectedItemsRow">
						<td>Sortera efter:</td>
						<td>
						<select id="sort-column" name="sort-column">
							<#list valuesForSortColumn as i>
								<#if i == sortColumn>
									<#switch i>
  										<#case "vgr:docTitle">
     										<option selected="yes" value="${i}">Dokumenttitel</option>
     										<#break>
  										<#case "vgr:docId">
     										<option selected="yes" value="${i}">DokumentID</option>
     										<#break>
  										<#case "vgr:docType">
     										<option selected="yes" value="${i}">Dokumenttyp</option>
     										<#break>
  										<#case "cm:versionLabel">
     										<option selected="yes" value="${i}">Version</option>
     										<#break>
     									<#case "vgr:createdByAuthor">
     										<option selected="yes" value="${i}">F&ouml;rfattare</option>
     										<#break>
     									<#case "vgr:responsibleName">
     										<option selected="yes" value="${i}">Ansvarig (Linjechef)</option>
     										<#break>
     									<#case "vgr:publishedAt">
     										<option selected="yes" value="${i}">Publiceringsdatum</option>
     										<#break>
  										<#default>
     										This will be processed if it is neither
									</#switch>
    							<#else>
    								<#switch i>
    									<#case "vgr:docTitle">
     										<option selected="yes" value="${i}">Dokumenttitel</option>
     										<#break>
  										<#case "vgr:docId">
     										<option value="${i}">DokumentID</option>
     										<#break>
  										<#case "vgr:docType">
     										<option value="${i}">Dokumenttyp</option>
     										<#break>
  										<#case "cm:versionLabel">
     										<option value="${i}">Version</option>
     										<#break>
     									<#case "vgr:createdByAuthor">
     										<option value="${i}">F&ouml;rfattare</option>
     										<#break>
     									<#case "vgr:responsibleName">
     										<option value="${i}">Ansvarig (Linjechef)</option>
     										<#break>
     									<#case "vgr:publishedAt">
     										<option value="${i}">Publiceringsdatum</option>
     										<#break>
  										<#default>
     										This will be processed if it is neither
									</#switch>
    							</#if>
   							</#list>
   						</select>
						</td>
					</tr>
		
					<tr class="selectedItemsRow">
						<td>Sorteringsordning:</td>
						<td><input type="checkbox" id="sort-desc" name="sort-desc" ${(showDescSort)!""} />Fallande</td>
					</tr>
					<tr>
					<td></td>
					<td align="right">
						<input type="button" class="button" value="F&ouml;rhandsgranska" onclick="preview(); return false;">
						<input type="button" class="button" value="F&ouml;reg&aring;ende" onclick="previousTab(); return false;">
						
						<#if editMode >
							<input type="submit" class="button" value="Uppdatera">
						<#else>
							<input type="submit" class="button" value="Spara">
						</#if>
					</td>
				</tr>
					</tbody>
    	 			</table>
    	 		</form>
    	 	</div>
    	 </div>
    	 
    	 <div id="preview" style="display:none;">
    	 	<br />
    	 	<h2>F&ouml;rhandsgranskning</h2>
    	 	<div id="preview-search" style="display:none;"></div>
    	 </div>
 	</div>
 	</div>
<script type="text/javascript">
	var tabView = null;
	(function() {
    	tabView = new YAHOO.widget.TabView('create-search');
    	YAHOO.log("The example has finished loading; as you interact with it, you'll see log messages appearing here.", "info", "example");
	})();

	function nextTab() {
		tabView.set('activeIndex', tabView.get('activeIndex') + 1);
	}

	function previousTab() {
		tabView.set('activeIndex', tabView.get('activeIndex') - 1);
	}
	
	tabView.on("activeTabChange", function(event) {
		if (tabView.get('activeIndex') == 2) {
			$("#preview").show();
		} else {
			$("#preview").hide();
		}
	});
	
	function preview() {
		var formData = $("#create-search-form").serialize();
		$.ajax({type: "POST", url: "${url.service}?preview",
			async: false, data: formData,
			success: function(msg) {
				element = $("#preview-search");
				element.html('');
				element.show();
				element.html('<img src="/alfresco/scripts/yui_vgr/build/assets/skins/sam/wait.gif" alt="Wait" />');
				setTimeout("element.load(encodeURI('/alfresco/service/vgr/resultlist?name=' + $('#list-name').val() + '_preview&format=html'))", 500);
			},
			error: function(msg) {
				element = $("#preview-search");
				element.html("<h3>Ett fel har intr&auml;ffat. F&ouml;rhandsgranskningen kunde inte visas.</h3>");
				element.show();
			}
		});
	}
</script>
 </body>
</html>